#ifndef D3DUTIL_H
#define D3DUTIL_H

#include <d3d9.h>
#include <d3dx9.h>
#include <dxerr.h>
#include <string>

//typedef RECT AABB;

enum CollisionState
{
	None, Left, Right, Bottom, Top
};

struct CollisionRECT{
public:
	float left;
	float top;
	float right;
	float bottom;
};

struct SceneRS{
public:
	int ID;
	std::string Info;
};

enum Action {DONOTHING, RUN, RUNFASTER, SHOOT, JUMP, GRASP, DIE, LAYDOWN, SWIM, SAYGOODBYE};

struct CollisionRS{
public:
	bool mCollided;
	CollisionState mState;
	float mCollideTime;
	bool isStart;
};

struct Collision1D{
public:
	float	mTEntry;
	float	mTExit;
	float	mDEntry;
	float	mDExit;
};

class D3DApp;
extern D3DApp*				gApp;
extern IDirect3DDevice9*	gDevice;
class Camera;
extern Camera*				gCamera;

#define LoadTextureEX(x,id) {if(x::checkType(id)){x::loadTexture();continue;}}
#define ReleaseTextureEX(x,id) {if(x::checkType(id)){x::releaseTexture();continue;}}
#define ReleaseCOM(x) { if(x){ x->Release();x = 0; } }

#ifndef HR
#define HR(x)                                      \
{                                                  \
	HRESULT hr = x;                                \
	if(FAILED(hr))                                 \
	{                                              \
		DXTrace(__FILE__, __LINE__, hr, #x, TRUE); \
	}                                              \
}
#endif
#endif